
window.onload=function(){
	//下一页按钮所在的div
	var wrap = document.getElementById("wrap");
	touch.on(wrap,"touchstart",function(e){
		var  event1=window.event||e;
//		event1.preventDefault();
	})
	touch.on(wrap,"swipeup",function(e){
		location.href = "five.html";
	});
	touch.on(wrap,"swipedown",function(e){
		location.href = "three.html";
	});
	
	var canvas=document.getElementById("mycanvas");
	var wrap=document.getElementById("wrap");
	var pen =canvas.getContext("2d");
	var deg=Math.PI/180;
	var wrapw=wrap.offsetWidth;
	
	var wraph=wrap.offsetHeight;
	canvas.width=wrapw;
	canvas.height=wraph;
	
	pen.translate(wrapw/2,wraph/2);
	pen.strokeStyle="white";
	pen.lineWidth=0.2;
	
	function line(x,z){
		
		var timer = setInterval(function(){
			
			pen.save();
			pen.rotate(z*deg);
			pen.beginPath();
			pen.moveTo(x,0);
			pen.lineTo(x-3,0);
			pen.closePath();
			pen.stroke();
			pen.restore();
			x-=3;
			if(x<10){
				clearInterval(timer);
				pen.arc(0,0,10,0,Math.PI*2,true);
				
				pen.fillStyle='rgb('+5+','+10+','+22+')';
				pen.fill();
			}
			
		},50);
		
	};
	
	setTimeout(function(){
		line(wrapw*0.21,-10);
		line(wrapw*0.29,45);
		line(wrapw*0.37,90);
		line(wrapw*0.29,135);
		line(wrapw*0.18,180);
		line(wrapw*0.42,230);
		line(wrapw*0.53,265);
		line(wrapw*0.45,-50);
		
	},5000);
	setTimeout(function(){
		line(wrapw/1.15,-110);
		line(wrapw/1.4,-80);
		line(wrapw/2.5,-75);
		line(wrapw/1.25,-65);
		line(wrapw/1.5,-40);
		line(wrapw/1.5,57);
		line(wrapw/2.3,65);
		line(wrapw/1.5,110);
		line(wrapw/2.3,120);
		line(wrapw/2.9,130);
		line(wrapw/2.8,150);
		line(wrapw/2.6,215);
		line(wrapw/3.0,267);
		line(wrapw/3.2,10);
	},6000)
	var imgtishi=document.getElementById("imgtishi");
	var timer1= setTimeout(function(){
		imgtishi.style.animation="span2 5s" ;
		imgtishi.style.animation="span2 1.5s infinite";

	},5000);
	var imgpsdiv=document.getElementById("imgps");
	var imgps=imgpsdiv.getElementsByTagName("img");
	var span1=document.getElementById("span1");
	var span2=document.getElementById("span2");
	var swipercontainer=document.getElementById("swiper-container");
	var swiperbuttonprev=document.getElementById("swiper-button-prev");
	var swiperbuttonnext=document.getElementById("swiper-button-next");
	var xxx;
	var mySwiper;
	var xback=document.getElementById("xback");
	setTimeout(function(){
		for(var i=0;i<imgps.length;i++){
		
		imgps[i].index = i;
		imgps[i].onclick=function(){
			
			imgpsdiv.style.opacity=0;
			span1.style.opacity=0;
			span2.style.opacity=0;
			clearTimeout(timer1)
			imgtishi.style.opacity=0;
			span1.style.opacity=0;
			swipercontainer.style.visibility="visible";
			imgtishi.style.animation="span2 1s" ;
			swiperbuttonprev.style.visibility="visible";
			swiperbuttonnext.style.visibility="visible";
			xback.style.visibility="visible";
			xxx=this.index;
			mySwiper = new Swiper('.swiper-container', {
			loop: true,
			initialSlide:xxx,
			// 如果需要前进后退按钮
			nextButton: '.swiper-button-next',
			prevButton: '.swiper-button-prev'
			
		});
		
		
			}
	
		}
		
	},800);
	
	xback.onclick=function(){
		xback.style.visibility="hidden"
		swiperbuttonprev.style.visibility="hidden";
		swiperbuttonnext.style.visibility="hidden";
		imgpsdiv.style.opacity=1;
		span1.style.opacity=1;
		span2.style.opacity=1;
		imgtishi.style.opacity=1;
		swipercontainer.style.animation="scale33 1s";
		setTimeout(function(){
			swipercontainer.style.visibility="hidden";
			swipercontainer.style.animation="";
			//swipercontainer.style.animation="scale33 1s";
		},1000);
	
		

	}
	
	
	
}
	
	
	
	
	
	


	
	
	
	

//封装一个数,可能是正也可能是负
function random(m,n){
	
	return Math.floor(Math.random()*(n-m+1)+m)
	
}









